<?php

/**
 * This is the model class for table "cedp".
 *
 * The followings are the available columns in table 'cedp':
 * @property integer $id
 * @property string $city
 * @property string $name
 * @property string $address
 * @property string $postal_code
 * @property string $phone
 * @property string $email
 * @property string $birthdate
 * @property string $job
 * @property string $school_name
 * @property string $school_address
 * @property string $school_phone
 * @property string $school_fax
 * @property string $school_email
 * @property string $class_choice
 * @property string $contact_via
 * @property string $handout_lang
 * @property string $created_at
 */
class Cedp extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Cedp the static model class
	 */
   
  public $verifyCode;
  
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cedp';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
      array('address, postal_code, birthdate, created_at, school_email, school_fax, school_address', 'safe'),
      array('email', 'email', 'message' => 'Please enter a valid email address.'),
			array('city, name, phone, email, job, school_name, school_phone, class_choice, contact_via, handout_lang', 'required'),
			array('city, name, address, postal_code, phone, email, birthdate, job, school_phone, school_email, class_choice, contact_via, handout_lang', 'length', 'max'=>500),
			array('school_name, school_address', 'length', 'max'=>1000),
      array('verifyCode', 'CaptchaExtendedValidator', 'allowEmpty'=>!CCaptcha::checkRequirements()),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, city, name, address, postal_code, phone, email, birthdate, job, school_name, school_address, school_phone, school_fax, school_email, class_choice, contact_via, handout_lang, created_at', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'city' => 'Kota',
			'name' => 'Nama Lengkap',
			'address' => 'Alamat',
			'postal_code' => 'Kode Pos',
			'phone' => 'Telepon',
			'email' => 'Email',
			'birthdate' => 'Tanggal Lahir',
			'job' => 'Posisi',
			'school_name' => 'Nama Sekolah / Gereja / Yayasan',
			'school_address' => 'Alamat',
			'school_phone' => 'Telepon',
			'school_fax' => 'Faks',
			'school_email' => 'Email',
			'class_choice' => 'Pilihan kelas',
			'contact_via' => 'Apabila ada informasi, silahkan menghubungi saya via',
			'handout_lang' => 'Mohon untuk memberi saya handout dalam bahasa',
			'created_at' => 'Created At',
		);
	}

  public function classChoice(){
    $array = array(
      'Class A: "Focus on Subject: How to Teach English as a Foreign Language"' => 'Class A: "Focus on Subject: How to Teach English as a Foreign Language"',
      'Class B: "Focus on Subject: How to Teach Science"' => 'Class B: "Focus on Subject: How to Teach Science"',
      'Class C: "Focus on Subject: How to Teach Social Studies"' => 'Class C: "Focus on Subject: How to Teach Social Studies"',
    );

    return $array;
  }

  public function contactVia(){
    $array = array(
      'Email' => 'Email',
      'Telepon' => 'Telepon'
    );

    return $array;
  }

  public function handoutLang(){
    return array(
      'Indonesia' => 'Indonesia',
      'Inggris' => 'Inggris',
    );
  }

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('postal_code',$this->postal_code,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('birthdate',$this->birthdate,true);
		$criteria->compare('job',$this->job,true);
		$criteria->compare('school_name',$this->school_name,true);
		$criteria->compare('school_address',$this->school_address,true);
		$criteria->compare('school_phone',$this->school_phone,true);
		$criteria->compare('school_fax',$this->school_fax,true);
		$criteria->compare('school_email',$this->school_email,true);
		$criteria->compare('class_choice',$this->class_choice,true);
		$criteria->compare('contact_via',$this->contact_via,true);
		$criteria->compare('handout_lang',$this->handout_lang,true);
		$criteria->compare('created_at',$this->created_at,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}